import 'package:flutter/material.dart';
import 'package:flutter_09_game/base/widget/base_list_more_get_builder.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/models/model_game_round_join.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/utils_bet_record.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/widgets/widget_bet_record_dropdown.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/widgets/widget_bet_record_top_crypto.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/widgets/widget_game_stats.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/widgets/widget_bet_record_item.dart';
import 'package:flutter_09_game/widgets/empty/empty_no_data.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'profile_bet_record_list_logic.dart';

class ProfileBetRecordListPage extends StatelessWidget {
  ProfileBetRecordListPage({super.key, required this.joinType});

  late final ProfileBetRecordListLogic logic = Get.put(
      ProfileBetRecordListLogic(joinType: joinType),
      tag: joinType.toString());
  final int joinType;

  @override
  Widget build(BuildContext context) {
    return BaseListMoreGetBuilder<ProfileBetRecordListLogic>(
        init: logic,
        // bottom: 16.w + ScreenUtil().bottomBarHeight
        tag: joinType.toString(),
        bodyTopViewBuilder: (_) {
          return Column(
            children: [
              WidgetBetRecordTopCrypto(
                  selectorTagRx: logic.selectorTagRx,
                  options: UtilsBetRecord.options),
              // WidgetBetRecordDropdown(
              //   statusRows: UtilsBetRecord.statusRows,
              //   timeRows: UtilsBetRecord.timeRows,
              //   symbolRows: UtilsBetRecord.symbolRows,
              //   symbolRx: logic.symbolRx,
              //   timeRx: logic.timeRx,
              //   statusRx: logic.statusRx,
              //   gameRows: UtilsBetRecord.gameRows,
              //   gameRx: logic.gameRx,
              //   editingController: logic.idController,
              //   onRequestRefresh: (value) {
              //     logic.refreshController.requestRefresh();
              //   },
              //   onTimeSelection: (value) {
              //     logic.updateTimeSelection(value);
              //   },
              // ),
            ],
          );
        },
        headerBuilder: (l) {
          return Visibility(
              visible: (logic.roundJoin.stats ?? []).isNotEmpty,
              child: WidgetGameStats(
                stats: logic.roundJoin.stats ?? [],
              ).marginOnly(top: 16.w, left: 16.w, right: 16.w)
              // showTRX: joinType == 2,
              );
        },
        builder: (_) {
          // bool showHeader = (logic.roundJoin.stats ?? []).isNotEmpty;
          // return CustomScrollView(
          //   slivers: [
          //     SliverPadding(
          //       padding: showHeader
          //           ? EdgeInsets.symmetric(
          //               horizontal: 16.w,
          //             ).copyWith(
          //               top: 16.w,
          //             )
          //           : EdgeInsets.zero,
          //       sliver: SliverToBoxAdapter(
          //           child: Visibility(
          //         visible: showHeader,
          //         child: WidgetGameStats(
          //           stats: logic.roundJoin.stats ?? [],
          //           // showTRX: joinType == 2,
          //         ),
          //       )),
          //     ),
          return logic.list.isNotEmpty
              ? SliverPadding(
                  padding: EdgeInsets.only(
                      bottom: 16.w + ScreenUtil().bottomBarHeight),
                  sliver: SliverList.builder(
                    itemCount: logic.list.length,
                    itemBuilder: (context, index) {
                      final item = logic.list[index];
                      return WidgetBetRecordItem(
                        data: item,
                      );
                    },
                  ),
                )
              : SliverToBoxAdapter(
                  child: SizedBox(
                    width: 1.sw,
                    child: Padding(
                      padding: EdgeInsets.only(top: 108.w),
                      child: EmptyNoData.notDataView(),
                    ),
                  ),
                  // )
                  // ],
                );
        });
  }
}
